<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
     <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
      <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<!-- Bootstrap core CSS -->
<link href="/admin/public/bootstrap.min.css" title="" rel="stylesheet" />
<link rel="stylesheet" href="/admin/css/plugins/toastr/toastr.min.css" />
<link href="/admin/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link href="/admin/public/animate.css" rel="stylesheet">
<link rel="stylesheet" href="/admin/public/inspinia.css" />
<link rel="stylesheet" href="/admin/css/templet_form.css" />
<link rel="stylesheet" type="text/css" href="${request.getContext }/admin/css/xcConfirm.css"/>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
	<script src="/admin/public/html5shiv.min.js"></script>
	<script src="/admin/public/respond.min.js"></script>
<![endif]-->
<style>
/*
	设置按钮里面字体的颜色
*/
table a {
    color: white !important;
}
/* 
	表格样式水平居中
*/
table tr th{
	text-align:center;
}
table tr td{
	vertical-align: middle !important;
	text-align:center;
}
</style>

<title>优惠券管理</title>
</head>
<body style="overflow-x:auto;min-width:1330px;">
	<div id="wrapper" class="container">
			<!--标编辑-->
			<div id="biaobj" class=" wrapper wrapper-content animated fadeInRight">
				<h3>优惠券管理</h3>
				<div class="right_box" id="right_box">
					<form action="/admin/system/coupon" class="form-horizontal">
						<div class="form-group">
							<label for="" class="control-label" style="width:80px;float:left;margin-left: 10px">优惠券编号:</label>
							<div class="col-lg-2 col-md-2 col-sm-2">
							<div  style="width:200px;float:left;">
								<input style="margin-left:-25px;" type="text" name="couponNum" id="couponNum" value="${couponNum }" class="form-control" />
								</div>
							</div>
							<button  style="width:82px;height:34px;background-color: #F8AC5A;border: none;" type="button" onclick="youhui();">搜索</button>
						</div>
						<div class="form-group">
							<label for="" class="control-label" style="width:80px;float:left;margin-left: 10px">批次编号:</label>
							<div class="col-lg-2 col-md-2 col-sm-2">
							<div  style="width:200px;float:left;">
								<input style="margin-left:-25px;" type="text" name="batchNum" id="batchNum" value="${batchNum }" class="form-control" />
								</div>
							</div>
							<label for="" class="control-label" style="width:80px;float:left;margin-left: 10px">批次名称:</label>
							<div class="col-lg-2 col-md-2 col-sm-2">
							<div  style="width:200px;float:left;">
								<input style="margin-left:-25px;" type="text" name="batchName" id="batchName" value="${batchName }" class="form-control" />
								</div>
							</div>
							<label for="" class="control-label" style="width:125px;float:left;margin-left: 10px">批次生成时间:</label>
							<div class="col-lg-2 col-md-2 col-sm-2">
								<div  style="width:250px;float:left;">
								<img style="position: relative;left:-20px; top: 6px" src="/admin/img/datePicker.gif"/>
			            		<input type="text" placeholder="开始时间" style="width:175px;float:left;" id="time" name="time" value="${time }" class= "form-control" onFocus="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd'})" />
			            		</div>
							</div>
							<button  style="width:82px;height:34px;" type="submit" class="col-lg-3 btn btn-success">搜索</button>
						</div>
						<button onclick="up()" style="width:90px;height:34px;margin-left:15px;" type="button" class="col-lg-3 btn btn-success">生成优惠券</button>
					</form>

					<!--表格部分-->
					<div class="ibox-content">
						<div class="row">
							<div class="col-sm-12">
								<table class="table table-striped table-bordered table-hover dataTables-example">
									<thead>
										<tr>
											<th>序号</th>
											<th>批次编号</th>
											<th>批次名称</th>
											<th>批次生成时间</th>
											<th>生成数量</th>
											<th>类型</th>
											<th>备注</th>
											<th>操作人</th>
											<th>更多</th>
										</tr>
									</thead>
									<tbody>
										<c:forEach items="${list }" var="list" varStatus="cw">
										<tr>
											<td>${cw.count }</td>
											<td>${list.batchNum }</td>
											<td>${list.batchName }</td>
											<td>${fn:substring(list.time,0,19)}</td>
											<td>${list.number }</td>
											<td>${list.couponType==0?'折扣券':'代金券' }</td>
											<td>${list.remark }</td>
											<td>${list.userName }</td>
											<td>
												<a onclick="edit('${list.batchId}');" class="up btn btn-primary btn-xs"><i class="fa fa-pencil"></i>详情</a>
												<a onclick="xiazai('${list.batchId}');" class="up btn btn-primary btn-xs"><i class="fa fa-pencil"></i>下载</a>
											</td>
										</tr>
										</c:forEach>
									</tbody>
								</table>
							</div>
						</div>
						<div class="row">
							<form action="" id="for" name="for" method="post">
								<input type="hidden" name="yehao" id="yin" value="1"> <input
									type="hidden" name="pagesize" id="tiaoshu"
									value="${page.pageSize }">
								<div class="fy">
									<span style="float: left;">每页条数：</span> <select
										style="width: 70px; float: left;"
										onchange="changeItem(this.value)" id="pagesize"
										name="pageSize">
										<option value="10" ${page.pageSize==10?'selected':'' }>10</option>
										<option value="20" ${page.pageSize==20?'selected':'' }>20</option>
										<option value="50" ${page.pageSize==50?'selected':'' }>50</option>
										<option value="100" ${page.pageSize==100?'selected':'' }>100</option>
										<option value="200" ${page.pageSize==200?'selected':'' }>200</option>
									</select>
									<div style="height: 27px;" class="col-sm-7">
										<div class="dataTables_paginate paging_simple_numbers"
											id="editable_paginate">
											<ul class="pagination pull-right" style="margin: -3px 0;">
												<li class="paginate_button previous" id="editable_previous">
													<a href="javascript:han(${page.pageNow-1 })"
													aria-controls="editable" data-dt-idx="0" tabindex="0">上一页</a>
												</li>
												<li class="paginate_button previous" id="editable_previous">
													<a aria-controls="editable" style="border: 0"
													data-dt-idx="0" tabindex="1"><input type="text"
														id="current"
														style="width: 32px; height: 19px; text-align: center;"
														value="${page.totalPageCount==0?0:page.pageNow}" /> /
														${page.totalPageCount }</a>
												</li>
												<li class="paginate_button previous" id="editable_previous">
													<a href="javascript:han(${page.pageNow+1 })"
													aria-controls="editable" data-dt-idx="0" tabindex="5">下一页</a>
													<a href="javascript:han($('#current').val())"
													aria-controls="editable" data-dt-idx="0" tabindex="5">跳转</a>
												</li>
											</ul>
										</div>
									</div>
									<div style="float: right;">总共${page.totalCount }条</div>
								</div>

							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- <iframe id="ifr" src="r_swiper.html" frameborder="no" scrolling="no" width="780px" height="100%" allowtransparency="true"></iframe> -->
		<iframe id="ifr" src="" frameborder="no" scrolling="no" width="780px"
		height="100%" allowtransparency="true"></iframe>
		<script src="/admin/public/jquery-1.11.3.js"></script>
		<script src="/admin/public/bootstrap.min.js" type="text/javascript"></script>
		<script src="/admin/js/plugins/lhgdialog/lhgdialog.js"></script>
		<script src="${request.getContextPath }/admin/My97/WdatePicker.js"></script>
		<!-- 弹出警示框 -->
		<script src="/admin/js/plugins/toastr/toastr.min.js"></script>
		<!-- 弹出确认框 -->
		<script src="/admin/public/artDialog4.1.7/artDialog.js?skin=blue"></script>
    	<script src="/admin/public/artDialog4.1.7/plugins/iframeTools.js"></script>
    	
    	<script src="/admin/js/templet_form.js"></script>
    	<script src="${request.getContext }/admin/js/xcConfirm.js" type="text/javascript" charset="utf-8"></script>
    	<script type="text/javascript">
    	function han(pn){
    		document.getElementById("yin").value=pn;
    		var biao=document.getElementById("for");
    		var coursesName =$("#coursesName").val();
    		//document.for.action="/courses/cournfo?coursesType=0&coursesName="+coursesName;
    		biao.submit();
    	}
    	function changeItem(size) {
    		document.getElementById("tiaoshu").value=size;
    		var biao=document.getElementById("for");
    		biao.submit();
    	 }
    	//生成优惠券
    	function up() {
			$.dialog({
				title : '添加',
				width : 900,
				height : 450,
				lock:true,
				content : 'url:/admin/system/addcoupon',
				init : function() {
				var iframe = this.iframe.contentWindow;
				var ul = iframe.document.getElementById('');
			},
			button : [
				{
					name : '保存',
					callback : function() {
					var iframe = this.iframe.contentWindow;
					var btn = iframe.document.getElementById('btnn').click();
						if (btn == true) {
							
						} else {
							
							return false;
						}
					},
					focus : true	

				}, {
						name : '取消',
						callback : function() {
		
						}
					} 
			]
			});
		}
    	//优惠券详情
		function edit(batchId) {
			window.location.href="/admin/system/youhui?batchId="+batchId;
		 }
		//优惠券搜索详情
    	function youhui() {
			var couponNum=$("#couponNum").val();
			$.dialog({
				title : '搜索',
				width : 1200,
				height : 580,
				lock:true,
				content : 'url:/admin/system/couponXQ?couponNum='+couponNum,
				init : function() {
				var iframe = this.iframe.contentWindow;
				var ul = iframe.document.getElementById('');
			},
			button : [
					 {
						name : '关闭',
						callback : function() {
		
						}
					 } 
					]
			});
		}
		//下载excel
		function xiazai(batchId){
			window.location.href="/admin/system/download?batchId="+batchId;
		}
    	</script>
</body>
</html>
